/*
 *  $TEAM_NAME Space Trader
 */
package views;

import models.Game;
import models.Galaxy;
import models.Player;



import presenters.MapPresenter;
import presenters.PrettyMarketPresenter;
import presenters.ShipyardPresenter;

import javax.swing.JPanel;
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;


/**
 * Hub Panel
 * @author twb
 *
 * @version $Revision: 1.0 $
 */
public class HubPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * field
	 */
	private final JButton menuButton;
    
	/**
	 * field
	 */
	private final JButton optionsButton;
	
    /**
	 * 
	 * Create the panel.
	 * @param game Game
     * @param frame JFrame
     */
	public HubPanel(Game game, JFrame frame) {
		super.setLayout(new BorderLayout(0, 0));
		
		final JPanel panel = new JPanel();
		super.add(panel, BorderLayout.SOUTH);
		
		menuButton = new JButton("Menu");
		panel.add(menuButton);
		
		optionsButton = new JButton("Options");
		panel.add(optionsButton);
		
		final JTabbedPane tabbedPane = new JTabbedPane(javax.swing.SwingConstants.TOP);
		super.add(tabbedPane, BorderLayout.CENTER);
		
		// Make the subviews
	    final Player player = game.getPlayer();
	    final Galaxy galaxy = game.getGalaxy();

		// Market
		//MarketPanel marketPanel = new MarketPanel(player);
		//MarketPresenter marketPresenter = new MarketPresenter(player, marketPanel);
        final PrettyMarketPanel marketPanel = new PrettyMarketPanel(player);
        final PrettyMarketPresenter marketPresenter = new PrettyMarketPresenter(
        		player, marketPanel);
        marketPresenter.setFrame(frame);
        
		tabbedPane.addTab("Market", null, marketPanel, null);
		
		// Pub
		//final JPanel pubPanel = new PubPanel();
		//tabbedPane.addTab("Pub", null, pubPanel, null);
		
		// Shipyard
		//JPanel shipPanel = new ShipyardPanel();
		final ShipyardPanel shipPanel = new ShipyardPanel(player);
		final ShipyardPresenter shipyardPresenter = new 
				ShipyardPresenter(player, shipPanel);
		shipyardPresenter.setFrame(frame);
		tabbedPane.addTab("Shipyard", null, shipPanel, null);
		
		// Map
		final MapPanel mapPanel = new MapPanel(player, galaxy);
		final MapPresenter mapPresenter = new MapPresenter(
				player, galaxy, game, mapPanel, frame);
		System.out.print(mapPresenter.toString());
		tabbedPane.addTab("Control Tower", null, mapPanel, null);
	}

	/**
	 * Method addActionListener.
	 * @param listener ActionListener
	 */
	public void addActionListener(ActionListener listener) {
        menuButton.addActionListener(listener);
        optionsButton.addActionListener(listener);
    }
}
